From: Bastien Nocera Date: Tue, 28 Apr 2020 15:24:06 +0000 (+0200) Subject: shell/global: Watch for switcheroo-control appearing X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~684^2^2~422 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=49605c7b000c06e68cdeab3bab079d5a25d208f3;p=gnome-shell.git shell/global: Watch for switcheroo-control appearing Rather than staticly expecting switcheroo-control to already be running on the system, wait for it appearing and disappearing. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1226 --- diff --git a/src/shell-global.c b/src/shell-global.c index 6ad7a6673..0488c3c44 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -299,6 +299,35 @@ shell_global_get_property(GObject *object, } } +static void +switcheroo_appeared_cb (GDBusConnection *connection, + const char *name, + const char *name_owner, + gpointer user_data) +{ + ShellGlobal *global = user_data; + + g_debug ("switcheroo-control appeared"); + shell_net_hadess_switcheroo_control_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, + G_DBUS_PROXY_FLAGS_NONE, + "net.hadess.SwitcherooControl", + "/net/hadess/SwitcherooControl", + global->switcheroo_cancellable, + switcheroo_control_ready_cb, + global); +} + +static void +switcheroo_vanished_cb (GDBusConnection *connection, + const char *name, + gpointer user_data) +{ + ShellGlobal *global = user_data; + + g_debug ("switcheroo-control vanished"); + g_clear_object (&global->switcheroo_control); +} + static void shell_global_init (ShellGlobal *global) { @@ -394,13 +423,13 @@ shell_global_init (ShellGlobal *global) g_object_unref, g_object_unref); global->switcheroo_cancellable = g_cancellable_new (); - shell_net_hadess_switcheroo_control_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, - G_DBUS_PROXY_FLAGS_NONE, - "net.hadess.SwitcherooControl", - "/net/hadess/SwitcherooControl", - global->switcheroo_cancellable, - switcheroo_control_ready_cb, - global); + g_bus_watch_name (G_BUS_TYPE_SYSTEM, + "net.hadess.SwitcherooControl", + G_BUS_NAME_WATCHER_FLAGS_NONE, + switcheroo_appeared_cb, + switcheroo_vanished_cb, + global, + NULL); } static void